package com.aaa.gs;

import com.aaa.gs.config.MyRule;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate;

/**
 * @fileName:GoodsApp
 * @description:
 * @author:忆尘
 * @createTime:2020/11/3 16:58
 * @version:1.0.0
 */
@SpringBootApplication
@MapperScan("com.aaa.gs.mapper")
@EnableEurekaClient //开启eureka的客户端，只对注册中心是eureka有效
//@EnableDiscoveryClient  //开启发现客户端，该注解可以是人已注册中心
@EnableTransactionManagement //开启事务
@RibbonClient(name = "goodsRiClient",configuration = MyRule.class)
public class GoodsApp {
    public static void main(String[] args) {
        SpringApplication.run(GoodsApp.class,args);
    }

    /**
     * 初始化配置
     * @return
     */
    @Bean  //<bean id="restTemplate" class="import org.springframework.web.client.RestTemplate">
    @LoadBalanced  //调用远程接口，要使用配置的负载均衡规则
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}
